Book: Phil Sturgeon “Build APIs You Won’t Hate”

By embracing the needs of modern applications, we create a new style of development where responsibilities for data storage and display are divided. On one side, we have various JS frameworks and mobile and desktop applications dedicated solely to presenting data and interacting with users. On the other hand, server applications are responsible for managing data storage and access authorization. While the first aspect has been extensively covered in numerous books and manuals, many authors need to pay more attention to the challenge of developing a quality API that handles the second aspect. For these reasons, Phil Sturgeon’s book “Build APIs You Won’t Hate” is a refreshing addition to the programming world.
This book is intended for developers tasked with building an API for the first time or who have previously developed one incorrectly. “Build APIs You Won’t Hate” aims to guide readers through the critical decisions required when planning an API for their application. It provides practical examples to help readers implement basic API functionality.
The principles for creating a reliable and well-designed API presented in the book are not tied to any specific programming language. However, to make the concepts easier to understand, the author chose PHP for the code examples, a language he uses daily.
The book is organized into fourteen logically sequenced chapters that follow the desirable flow of events during API development.
It starts with explanations on creating “test data” for development, planning, defining access points, and specifying the system’s input/output parameters. This is followed by insights on testing API behavior and hiding data implementation from its presentation. The book offers a comprehensive review of user authentication methods, analyzing the advantages and disadvantages of each. This will help you make informed decisions, such as whether OAuth 2.0 or another solution is necessary.
Documentation is a step no developer enjoys, but when building an application that communicates with others, comprehensive documentation becomes necessary rather than optional. This book teaches how to simplify this process using existing user-friendly tools and ensure professional-looking documentation with minimal effort.
The final chapter explains the importance of enabling data export in various formats, such as JSON, XML, YAML, and CSV. It addresses questions like why users should be able to choose their preferred data format and why implementing HATEOAS is the final essential step to make your API truly RESTful.
“Build APIs You Won’t Hate” offers the author’s approach to API implementation, testing, and documentation creation. Written with a global perspective to be accessible to developers regardless of their programming language, the code examples in the book are far more practical and useful than those typically found in tutorials.
When discussing API response formats, the author analyzes and compares APIs from major companies like Facebook and Twitter, highlighting the strengths and weaknesses of their implementations. This approach is particularly valuable, as it familiarizes readers with good and bad practices.
The author’s writing style balances explaining the methodology - answering why specific approaches are recommended - and providing concrete examples of how to implement them using PHP and tools created by the author. My main criticism is the lack of consistency in focusing on one perspective. However, some might consider this the book’s greatest strength.
This book addresses challenges you may encounter during API development, and I highly recommend it to developers who have yet to gain prior experience in this area. By applying the principles outlined in the book, you’ll discover many shortcuts that were unavailable a few years ago when I first needed to develop my own API.
Now, go ahead and find a copy of Phil Sturgeon’s “Build APIs You Won’t Hate” to complete your work efficiently and effectively.